package com.mall.b2c.domain.order;

import java.math.BigDecimal;
import java.util.Date;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.OneToMany;
import javax.persistence.OneToOne;
import javax.persistence.OrderBy;
import javax.persistence.Table;
import javax.persistence.Transient;

import com.mall.b2c.enums.RefundStatus;
import com.mall.common.domain.BaseEntity;

@Entity
@Table(name = "b2c_refund")
public class RefundDomain extends BaseEntity {

	private static final long serialVersionUID = 5340048014994576481L;
	private String refundNo;// 退款编号
	private RefundStatus refundStatus;// 退款状态
	private Boolean isChange;//是否换货
	private String consignee; //收货人
	private String areaName; //收货人地区
	private Long areaId;
	private String address;// 收货人地址
	private String contact;// 收货人联系方式
	private String remark;// 备注
	private BigDecimal amount;//退款金额

	private String productName;// 商品名称
	private String productCode;// 商品编号
	private String image;// 商品图片
	private String specification;// 规格
	private BigDecimal salePrice;// 价格
	private BigDecimal weight; // 重量
	private Integer quantity;// 数量

	private String batch;// 批次号
	private Date manufacturerDate; // 生产日期
	private Date validDate;// 有效日期
	
	private String logisticsNo;//快递单号
	private String deliveryMethodName;//配送方式
	private BigDecimal shipFee;//快递费
	
	private String orderNo; //订单编号
	
	private Set<RefundLogDomain> logs;
	private OrderItemDomain orderItem;
	
	@Transient
	public BigDecimal getSubtotal(){
		if(amount != null){
			return amount;
		}
		return salePrice.multiply(new BigDecimal(quantity));
	}

	public String getOrderNo() {
		return orderNo;
	}

	public void setOrderNo(String orderNo) {
		this.orderNo = orderNo;
	}

	public String getRefundNo() {
		return refundNo;
	}

	public void setRefundNo(String refundNo) {
		this.refundNo = refundNo;
	}

	public RefundStatus getRefundStatus() {
		return refundStatus;
	}

	public void setRefundStatus(RefundStatus refundStatus) {
		this.refundStatus = refundStatus;
	}

	public Boolean getIsChange() {
		return isChange;
	}

	public void setIsChange(Boolean isChange) {
		this.isChange = isChange;
	}

	public String getConsignee() {
		return consignee;
	}

	public void setConsignee(String consignee) {
		this.consignee = consignee;
	}

	public String getAreaName() {
		return areaName;
	}

	public void setAreaName(String areaName) {
		this.areaName = areaName;
	}

	public String getAddress() {
		return address;
	}

	public void setAddress(String address) {
		this.address = address;
	}

	public String getContact() {
		return contact;
	}

	public void setContact(String contact) {
		this.contact = contact;
	}

	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	public String getProductName() {
		return productName;
	}

	public void setProductName(String productName) {
		this.productName = productName;
	}

	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}

	public String getImage() {
		return image;
	}

	public void setImage(String image) {
		this.image = image;
	}

	public String getSpecification() {
		return specification;
	}

	public void setSpecification(String specification) {
		this.specification = specification;
	}

	public BigDecimal getSalePrice() {
		return salePrice;
	}

	public void setSalePrice(BigDecimal salePrice) {
		this.salePrice = salePrice;
	}

	public BigDecimal getWeight() {
		return weight;
	}

	public void setWeight(BigDecimal weight) {
		this.weight = weight;
	}

	public Integer getQuantity() {
		return quantity;
	}

	public void setQuantity(Integer quantity) {
		this.quantity = quantity;
	}

	public String getBatch() {
		return batch;
	}

	public void setBatch(String batch) {
		this.batch = batch;
	}

	public Date getManufacturerDate() {
		return manufacturerDate;
	}

	public void setManufacturerDate(Date manufacturerDate) {
		this.manufacturerDate = manufacturerDate;
	}

	public Date getValidDate() {
		return validDate;
	}

	public void setValidDate(Date validDate) {
		this.validDate = validDate;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	@OneToMany(fetch=FetchType.LAZY,mappedBy="refund",cascade={CascadeType.ALL})
	@OrderBy("createDate")
	public Set<RefundLogDomain> getLogs() {
		return logs;
	}

	public void setLogs(Set<RefundLogDomain> logs) {
		this.logs = logs;
	}

	@OneToOne(fetch=FetchType.LAZY,mappedBy="refund")
	public OrderItemDomain getOrderItem() {
		return orderItem;
	}

	public void setOrderItem(OrderItemDomain orderItem) {
		this.orderItem = orderItem;
	}

	public Long getAreaId() {
		return areaId;
	}

	public void setAreaId(Long areaId) {
		this.areaId = areaId;
	}

	public String getLogisticsNo() {
		return logisticsNo;
	}

	public void setLogisticsNo(String logisticsNo) {
		this.logisticsNo = logisticsNo;
	}

	public String getDeliveryMethodName() {
		return deliveryMethodName;
	}

	public void setDeliveryMethodName(String deliveryMethodName) {
		this.deliveryMethodName = deliveryMethodName;
	}

	public BigDecimal getShipFee() {
		return shipFee;
	}

	public void setShipFee(BigDecimal shipFee) {
		this.shipFee = shipFee;
	}

}
